package com.laikan.reader.bookfriend.adapter.impl;

import android.content.Context;
import android.net.Uri;
import android.view.View;
import android.widget.TextView;
import com.facebook.drawee.view.SimpleDraweeView;
import com.laikan.reader.R;
import com.laikan.reader.bookfriend.adapter.BaseListAdapter;
import com.laikan.reader.bookfriend.entity.ItemBookBean;
import com.laikan.reader.bookfriend.holder.LViewHolder;
import com.laikan.reader.bookfriend.utils.Constant;
import com.laikan.reader.bookfriend.utils.ImageUtils;
import com.laikan.reader.bookreader.activity.BookDesActivity;

/**
 * Created by lingyt on 2016/11/18.
 * 作品页adapter
 */
public class BookAdapter extends BaseListAdapter<ItemBookBean> {
    
    public BookAdapter(Context context, int layoutId) {
        super(context, layoutId);
    }

    @Override
    protected void convert(LViewHolder holder, final ItemBookBean bean) {

        //initView
        SimpleDraweeView icon = holder.getView(R.id.item_iv_icon);
        TextView title = holder.getView(R.id.item_tv_title);
        TextView tvTypeAndName = holder.getView(R.id.item_tv_book_type);
        TextView tvIntrodu = holder.getView(R.id.tv_record);

        //initData
        icon.setImageURI(Uri.parse(bean.icon));
        title.setText(bean.name);
        tvIntrodu.setText(bean.introduce);
        String typeStr = bean.sortName +"|"+bean.authorName;
        tvTypeAndName.setText(typeStr);

        //setListener
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                //跳转到书籍详情页
                ImageUtils.startActivity(BookDesActivity.class, Constant.BOOK_ID,bean.id);

            }
        });
    }
}
